elf: Add kprobe EventNameOption for unique eventName per Module #293
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#251 : can't attach two functions for the same kprobe event
#271 : make uprobe eventname with symbol address (maybe similar issue)
Intention
Currently, gobpf/elf Module make kprobe eventName like this:
gobpf/elf/module.go
Line 359 in 2289761
gobpf/elf/module.go
Lines 746 to 751 in 2289761
Such a naming works well when we use it temporarily.
However, this situation can happen: (Also I get stuck)
*The Kernel document says that we can actually attach two different probes at the same address.
https://www.kernel.org/doc/Documentation/kprobes.txt : 5. Kprobes Features and Limitations
I know that this issue is a little tricky to handle in the library. I tried to fix this issue in my use.
But It was much more tricky to handle unexported fields and methods... So I made this PR.
Changed Files
elf/module.go
: Add a fieldkprobeEvOpts EventNameOption
inModule
therefore we can seperate a namespace of each Module.elf/module_unsupported.go
: Adjust for unsupported moduleNeed to Fix
TrySetKprobeEventNameOpts()
to the constructor ofelf.Module
(?)- There are already 4 constructor in
elf.Module
such as... :NewModuleWithLog
,NewModuleFromReaderWithLog
,NewModule
,NewModuleFromReader
. Therefore I didn't make additional constructor.